package com.example.heimaai.repository;

import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class InMemoryChatHistoryRepository implements ChatHistoryRepository{
    //定义一个map存储不同类别的chatIds
    private final Map<String,List<String>> chatHistory= new HashMap<>();
    @Override
    public void save(String type,String chatId) {
        List<String> list = chatHistory.getOrDefault(type, new ArrayList<String>());
        list.add(chatId);
        chatHistory.put(type,list);
    }

    @Override
    public List<String> getChatIds(String type) {
        return chatHistory.getOrDefault(type, new ArrayList<String>());
    }
}
